home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / m68k / fbug68k.arc / HE.C < prev    next >
C/C++ Source or Header  |  1989-08-17  |  2KB  |  85 lines

  1. #include"userdef.h"
  2.  
  3. /* ****************************************************** */
  4. /* 
  5. He [<name>]||[<syntax>]
  6. Help -> This command prints out the commands and their syntax.
  7.  
  8. The object of this command is to provide the user with help
  9. in inputing commands by providing the syntax expected by each
  10. command.
  11.  
  12. The "he " is stripped off. If only one argument is on the command
  13. line, then a list of all the commands is printed. If more than one
  14. argument on the command line, the command list and syntax list is
  15. searched for a match. If none is found, then an error message is printed.
  16. If a match is found, then a message describing the command or syntax is
  17. printed.
  18. While printing out the command list, if the number of commands exceeds the
  19. number the screen can hold, then a message is printed and output is halted
  20. until the user hits any key.
  21. */
  22. /* ****************************************************** */
  23.  
  24. hecmd(argc,argv)
  25. int argc;    /* number of arguments on command line */
  26. char *argv;    /* command line */
  27. {
  28. extern struct table_element f[];    /* table of commands */
  29. extern struct syntax_element syn[];    /* table of syntaxes */
  30. register int i,j;            /* loop counters */
  31.  
  32.     striparg(argv);
  33.     switch (argc)
  34.     {
  35.         case 1:
  36.             for (j=0,i=0;f[i].nptr != LASTCMD;i++,j++)
  37.             {
  38.                 print(f[i].nptr);
  39.                 if(check())
  40.                     break;
  41.                 if (j == MAXSCREEN)
  42.                 {
  43.                     j = 0;
  44.                     print(HITKEYMSG);
  45.                     getch(TERMINAL,FALSE);
  46.                 }
  47.             }
  48.             break;
  49.         case 2:    
  50.             for (i=0;f[i].nptr != LASTCMD;i++)
  51.             {
  52.                 for (j=0;f[i].nptr[j] != ENDCMD && argv[j] == f[i].nptr[j];j++)
  53.                     ;
  54.                 if (f[i].nptr[j] == ENDCMD && whitesp(argv[j]))
  55.                     break;
  56.             }
  57.             if (f[i].nptr != LASTCMD)
  58.             {
  59.                 print(f[i].nptr);
  60.                 print(f[i].syntax);
  61.             }
  62.             else
  63.             {
  64.                 print("[] => optional, <> => required, || => or, ... => repeated\n");
  65.                 for(i=0;syn[i].desc != LASTCMD;i++)
  66.                 {
  67.                     for(j=0;syn[i].desc[j] != ENDCMD && argv[j] == syn[i].desc[j];j++)
  68.                         ;
  69.                     if (syn[i].desc[j] == ENDCMD && whitesp(argv[j]))
  70.                         break;
  71.                 }
  72.                 if (syn[i].desc != LASTCMD)
  73.                     print(syn[i].desc);
  74.                 else
  75.                     print(UNKNOWNMSG);
  76.             }
  77.             break;
  78.         default:
  79.             print(ERR01);
  80.     }
  81. }
  82.  
  83. /* ************************************************* */
  84.  
  85.